/*	Copyright
 
 This file falls within the license domain specified in "IAGraphics.h"
 */


#import "CGPathAdjunct.h"



void	CGPathAddCircleAtPoint	( CGMutablePathRef path , const CGAffineTransform *m , CGPoint center , CGFloat radius ) {
	CGFloat radius2 = radius * 2. ;
	CGRect rect = { center.x-radius , center.y-radius , radius2 , radius2 } ;
	CGPathAddEllipseInRect ( path , m , rect ) ;
}




void	CGPathAddLineBetweenPoints	( CGMutablePathRef path , const CGAffineTransform *m , CGPoint pt1 , CGPoint pt2 ) {
	CGPathMoveToPoint ( path , m , pt1.x , pt1.y ) ;
	CGPathAddLineToPoint ( path , m , pt2.x , pt2.y ) ;
}



void	CGPathAddRoundedRect		( CGMutablePathRef path , const CGAffineTransform *m , CGRect rect , CGFloat radius ) {
	CGFloat				maxX		=	CGRectGetMaxX(rect) ;
	CGFloat				minX		=	CGRectGetMinX(rect) ;
	CGFloat				maxY		=	CGRectGetMaxY(rect) ;
	CGFloat				minY		=	CGRectGetMinY(rect) ;
	static CGFloat		pi			=	3.141592653589793238 ;
	static CGFloat		piOver2		=	3.141592653589793238 / 2. ;
	static CGFloat		pi3Over2	=	3. * 3.141592653589793238 / 2. ;
	
    CGPathMoveToPoint	( path,0 , minX+radius , minY ) ;
    CGPathAddArc		( path,0 , maxX-radius , minY+radius , radius , pi3Over2	, 0			, 0 ) ;
    CGPathAddArc		( path,0 , maxX-radius , maxY-radius , radius , 0			, piOver2	, 0 ) ;
    CGPathAddArc		( path,0 , minX+radius , maxY-radius , radius , piOver2		, pi		, 0 ) ;
    CGPathAddArc		( path,0 , minX+radius , minY+radius , radius , pi			, pi3Over2	, 0 ) ;
}

